package com.xz.disk.controller;

import com.xz.disk.utils.ResponseResult;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: disk
 * @description: 用户
 * @author: Shawn
 * @create: 2020-08-04 10:14
 **/
@RestController
@RequestMapping("/user")
public class AdminController {
    @Value("${admin.username}")
    private String username;
    @Value("${admin.password}")
    private String password;


    @Data
    class User{
        String username;
        String password;
    }

    @PostMapping("/login")
    public ResponseResult login(User user){
        if(!this.username.equals(user.getUsername())){
            return ResponseResult.ERROR("用户名不存在");
        }
        if(!this.password.equals(user.getPassword())){
            return ResponseResult.ERROR("密码不正确");
        }
        return ResponseResult.SUCCESS("登陆成功",user);
    }
}